import unittest


# 用户类
class User():


    def __init__(self,username,password):
        self.username = username
        self.password = password
    # 用户登录
    def login(self):
        if self.username =="admin" :
            if self.password == "admin":
                return {"msg":"登录成功"}
            else:
                return {"msg":"密码错误"}
        else:
            return {"msg":"用户名错误"}


class TestUser(unittest.TestCase):

    def testLogin1(self):
        # 创建用户对象
        user= User("admin","admin")
        result = user.login()
        # 断言
        self.assertEqual("登录成功",result["msg"])

    def testLogin2(self):
        # 创建用户对象
        user = User("admin", "123")
        result = user.login()
        # 断言
        self.assertEqual("密码错误", result["msg"])

    def testLogin3(self):
        # 创建用户对象
        user = User("admin1", "123")
        result = user.login()
        # 断言
        self.assertEqual("用户名错误", result["msg"])